﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Hotel.NhanVien
{
    public partial class Reportdanhsachnhanvien : Form
    {
        //Frmmain parent;
        SqlConnection conn = new SqlConnection("Server=(local);DataBase=Hotel;Integrated Security=SSPI");
        public Reportdanhsachnhanvien()
        {
            InitializeComponent();
            //this.parent = _parent;
        }

        private void Reportdanhsachnhanvien_Load(object sender, EventArgs e)
        {
            CrystalReportDanhsachnhanvien rpt = new CrystalReportDanhsachnhanvien();
            DataTable dt = null;
            string sql = " SELECT TenNV, NgaySinh, SoDT, DiaChi, NgayVaoLam, TenNhom FROM dbo.NhanVien WHERE (DaXoa = 0) ";
            SqlCommand cmd;
            try
            {
                conn.Open();
                SqlDataAdapter da = new SqlDataAdapter(sql,conn);
                dt = new DataTable();
                da.Fill(dt);
                rpt.SetDataSource(dt);
                rpt.Refresh();
                crystalReportDanhsachnhanvien.ReportSource = rpt;
                crystalReportDanhsachnhanvien.Refresh();
            }
            catch (Exception ev)
            {
                MessageBox.Show(ev.Message);

            }
            finally
            {
                conn.Close();
            }
            
        }
        
    }
}
